#pragma once

#include <string>

using std::string;

namespace yazi{
namespace socket{

class Socket{
    friend class SocketHandler;
public:
    Socket();
    Socket(const string& ip, const int port);
    virtual ~Socket();

    bool bind();
    bool listen(const int maxConnection);
    int accept();
    bool connect(const string& ip, const int port);
    void close();

    int recv(char* buf, int len);
    int send(const char* buf, int len);

    bool set_nonblock();
    bool set_recv_buffer(const int buf_len);
    bool set_send_buffer(const int buf_len);
    bool set_linger(bool active, int seconds);
    bool set_keep_alive();
    bool set_reuse_addr();
    bool set_reuse_port();

protected:
    string m_ip;
    int    m_port;
    int    m_sockfd;
};




}}